#pragma once
#include <array>

using namespace std;

template<class T, int size>
class stack
{
private:
	array<T, size> a;
	int top;
public:

	stack()
	{
		top = -1;
	}

	~stack()
	{
	}

	void push(T value)
	{
		if ((top + 1) >= a.size())
			throw exception("stack<T> is full, can not push to full stack");
		top++;
		a[top] = value;
	}

	T& pop()
	{
		if (top == -1)
			throw exception("stack<T> is empty, can not pop from empty stack");
		int i = top;
		top--;
		return a[i];
	}

	int empty_space() { return a.size() - top - 1; }
	int size() { return top + 1; }

	bool is_empty() { return top == -1; }
	bool is_full() { return top == (a.size() - 1); }
};

